/*
 *   This File is Part of CuteOgre Game Engine
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *	Copyright 2010 Alexandre Pires ( c.alexandre.pires@gmail.com )
 *  Created on: 2010/08/22
 */

#ifndef SOUNDMANAGER_H_
#define SOUNDMANAGER_H_

#include "IManager.h"

#include <QMutex>
#include <QStringList>
#include <QQueue>

#include <Singleton.h>

#include "AL/al.h"
#include "AL/alc.h"
#include "AL/alext.h"

#include "FormatData.h"

#define OGG_VIDEO_BUFFER_SIZE (4096)
#define NUM_BUFFERS 10

class SoundManager : public QObject, public IManager, public Singleton<SoundManager> {
	Q_OBJECT
public:
	enum SoundMode {
		ModeIdle = 0x0,
		ModeNormal = 0x1,
		ModeOpenAl = 0x2
	};
public:
	SoundManager ( QObject* rParent = 0 );
	virtual ~SoundManager();
public:
	static SoundManager& getSingleton(void);
	static SoundManager* getSingletonPtr(void);
private:
	void readSettings ();
	QStringList getDeviceList ();
	void checkFeatureSupport();
public:
	void switchMode ( SoundMode rMode );
	SoundMode getMode () const;
	void init ();
	void shutdown ();
private:
	SoundMode mMode;
	bool mShutdown;

	// OpenAL
	bool mEAXSupport;
	int mMajorVersion, mMinorVersion, mEAXVersion;
	QString mDeviceName;
	ALCcontext* mContext;
	ALCdevice* mDevice;
	FormatMap mSupportedFormats;
};

#endif /* SOUNDMANAGER_H_ */
